package com.xuecheng.content.controller;

import com.xuecheng.api.content.CourseAuditApi;
import com.xuecheng.api.content.model.dto.CourseBaseDTO;
import com.xuecheng.api.content.model.qo.QueryCourseBaseModel;
import com.xuecheng.api.content.model.vo.CourseAuditVO;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.content.convert.CourseBaseConvert;
import com.xuecheng.content.service.CourseBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CourseAuditController implements CourseAuditApi {

    // 平台机构标识，该标识可以查询所有教学机构课程
    public static final Long OPERATION_FLAG = -99887799L;

    @Autowired
    private CourseBaseService courseBaseService;

    /**
     * 分页条件查询课程信息 - 运营平台
     *
     * @param params
     * @param model
     * @return
     */
    @PostMapping("m/course/list")
    public PageVO<CourseBaseDTO> queryCourseList(PageRequestParams params, @RequestBody QueryCourseBaseModel model) {
        return courseBaseService.queryCourseBaseList(params, model, OPERATION_FLAG);
    }

    /**
     * 审核课程 - 运营平台
     *
     * @param auditVO
     */
    @PostMapping("m/courseReview/approve")
    public void approveCourse(@RequestBody CourseAuditVO auditVO) {
        CourseBaseDTO dto = CourseBaseConvert.INSTANCE.audit2dto(auditVO);
        courseBaseService.approveCourse(dto);
    }

}
